<?php
namespace app\common\validate\User;
use think\Validate;
// 用户的验证器
class User extends Validate{
	/**
	 * 定义验证规则
	 * 格式：'字段名' => ['规则1','规则2'...]
	*/
    protected $rule = [
	   'email' => 'require|email|unique:user',
	   'password' => 'require',//必填
	   'salt' => 'require',
	   'nickname' => 'require',
	   'sex' => 'in:0,1,2', //字段范围
	   'point' => 'egt:0',  //给字段大于等于0
	   'vip' => 'egt:0',
	   'auth' => 'in:0,1',
	   'openid' => 'unique:user',  //openid必须是唯一值
    ];
	
	/**
	 * 定义验证规则
	 * 格式：'字段名.规则名' => '错误信息'
	*/
	protected $message = [
	   'email.require' => '邮箱必填',
	   'email.email' => '格式必须是邮箱',
	   'email.unique' => '该邮箱已注册，请重新填写',
	   'nickname.require'  => '昵称必填',
	   'password.require' => '密码必填',
	   'salt.require' => '密码盐生成有误，请稍后重试',
	   'sex.in' => '选择的性别有误，请重新选择',
	   'point.egt' => '积分不能小于0',
	   'vip.egt' => 'vip等级不能小于0',
	   'auth.in' => '您的验证状态有误请重新操作',
	];
	
	/* 
		验证场景
	*/
	protected $scene = [
		'vue' => ['email','password','salt','point','sex','vip','auth']
	];
}
?>
